package com.daily.expenses.database;

import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

public class RecordsTable {

	// Database table
	/* was: 
	public static final String TABLE_RECORDS = "todo";
	public static final String COLUMN_ID = "_id";
	public static final String COLUMN_CATEGORY = "category";
	public static final String COLUMN_SUMMARY = "summary";
	public static final String COLUMN_DESCRIPTION = "description";
	*/
	public static final String TABLE_RECORDS = "records";
	public static final String COLUMN_ID = "_id";
	public static final String COLUMN_CATEGORY = "category";
	public static final String COLUMN_TITLE = "title";
	public static final String COLUMN_DESCRIPTION = "description";
	public static final String COLUMN_DATE_YEAR = "date_year";
	public static final String COLUMN_DATE_MONTH = "date_month";
	public static final String COLUMN_DATE_DAY = "date_day";
	public static final String COLUMN_AMOUNT = "amount";

	// Database creation SQL statement
	private static final String DATABASE_CREATE = "create table "
	+ TABLE_RECORDS + "( " 
			+ COLUMN_ID + " integer primary key autoincrement, " 
			+ COLUMN_CATEGORY + " text not null, " 
			+ COLUMN_TITLE + " text not null," 
			+ COLUMN_DESCRIPTION + " text not null," 
			+ COLUMN_AMOUNT + " long not null," 
			+ COLUMN_DATE_YEAR + " integer not null,"
			+ COLUMN_DATE_MONTH + " integer not null," 
			+ COLUMN_DATE_DAY + " integer not null" 
	+ ");";

	public static void onCreate(SQLiteDatabase database) {
		database.execSQL(DATABASE_CREATE);
	}

	public static void onUpgrade(SQLiteDatabase database, int oldVersion,
			int newVersion) {
		Log.w(RecordsTable.class.getName(), "Upgrading database from version "
				+ oldVersion + " to " + newVersion
				+ ", which will destroy all old data");
		database.execSQL("DROP TABLE IF EXISTS " + TABLE_RECORDS);
		onCreate(database);
	}
}
